import React from 'react';
import { format } from '@/utils/datetime';
import CommonPage from '@/components/page/CommonPage';
import { useModel } from 'umi';
const daoName = 'IndiLoanPl';
const importName = 'IndiLoanPl';
const columns: API.Column[] = [
  {
    title: '证件号码',
    dataIndex: 'IDNO',
    key: 'IDNO',
    width: 180,
    sorter: true,
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '借据号',
    dataIndex: 'EVNO',
    key: 'EVNO',
    width: 150,
    sorter: true,
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '客户名称',
    width: 120,
    sorter: true,
    dataIndex: 'KHMC',
    key: 'KHMC',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '批量方式',
    width: 190,
    sorter: true,
    dataIndex: 'ISTZCaption',
    key: 'ISTZ',
    dispaly: true,
    filter: true,
    export: false,
  },
  {
    title: '分户日期',
    width: 120,
    sorter: true,
    key: 'DSDT',
    dataIndex: 'DSDT',
    render: (data) => format(data, 'yyyy-MM-dd'),
    export: true,
    dispaly: true,
    filter: true,
  },
  {
    title: '导入结果',
    width: 150,
    sorter: true,
    key: 'CLJG',
    dataIndex: 'CLJG',
    export: false,
    dispaly: true,
    filter: false,
  },
  {
    title: '员工工号1',
    width: 140,
    sorter: true,
    key: 'EMNO1',
    dataIndex: 'EMNO1',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '分成比例1(%)',
    width: 150,
    sorter: true,
    key: 'ZB1',
    dataIndex: 'ZB1',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '员工工号2',
    width: 140,
    sorter: true,
    key: 'EMNO2',
    dataIndex: 'EMNO2',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '分成比例2(%)',
    width: 150,
    sorter: true,
    key: 'ZB2',
    dataIndex: 'ZB2',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '员工工号3',
    width: 140,
    sorter: true,
    key: 'EMNO3',
    dataIndex: 'EMNO3',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '分成比例3(%)',
    width: 150,
    sorter: true,
    dataIndex: 'ZB3',
    key: 'ZB3',
    dispaly: true,
    filter: true,
    canEdit: false,
    export: true,
  },
];
const controls: API.Control[] = [
  {
    name: 'IDNO',
    rules: [
      { required: true, message: '不能为空' },
      { min: 1, max: 50, message: '最小为1，最大为50' },
    ],
    type: 'text',
    label: '证件号码',
    grid: 12 / 24,
  },
  {
    name: 'EVNO',
    rules: [
      { required: true, message: '不能为空' },
      { min: 1, max: 50, message: '最小为1，最大为50' },
    ],
    type: 'text',
    label: '借据号',
    grid: 12 / 24,
  },
  {
    name: 'KHMC',
    rules: [
      { required: true, message: '不能为空' },
      { min: 1, max: 50, message: '最小为1，最大为50' },
    ],
    type: 'text',
    label: '客户名称',
    grid: 12 / 24,
  },
  {
    name: 'ISTZ',
    rules: [
      { required: true, message: '不能为空' },
      { min: 1, max: 50, message: '最小为1，最大为50' },
    ],
    type: 'radio-group',
    options: [
      { value: '0', label: '处理未分配客户' },
      { value: '1', label: '调整已分配客户' },
    ],
    label: '批量方式',
    grid: 12 / 24,
    initValue: '0',
  },
  {
    name: 'DSDT',
    rules: [
      { required: true, message: '不能为空' },
      { min: 1, max: 50, message: '最小为1，最大为50' },
    ],
    type: 'date',
    label: '分户日期',
    dataType: 'date',
    grid: 12 / 24,
    placeholder: '请选择分户日期...',
  },
  {
    name: 'EMNO1',
    rules: [{ required: true, message: '不能为空' }],
    type: 'text',
    label: '员工工号1',
    grid: 12 / 24,
  },
  {
    name: 'ZB1',
    rules: [
      { required: true, message: '不能为空' },
      { min: 1, max: 50, message: '最小为1，最大为50' },
    ],
    type: 'number',
    label: '分成比例1(%)',
    dataType: 'number',
    grid: 12 / 24,
  },
  {
    name: 'EMNO2',
    rules: [
      { required: false, message: '不能为空' },
      { min: 1, max: 50, message: '最小为1，最大为50' },
    ],
    type: 'text',
    label: '员工工号2',
    grid: 12 / 24,
  },
  {
    name: 'ZB2',
    rules: [
      { required: false, message: '不能为空' },
      { min: 1, max: 50, message: '最小为1，最大为50' },
    ],
    type: 'number',
    label: '分成比例2(%)',
    dataType: 'number',
    grid: 12 / 24,
  },
  {
    name: 'EMNO3',
    rules: [{ required: false, message: '不能为空' }],
    type: 'text',
    label: '员工工号3',
    grid: 12 / 24,
  },
  {
    name: 'ZB3',
    rules: [{ required: false, message: '不能为空' }],
    type: 'number',
    label: '分成比例3(%)',
    dataType: 'number',
    grid: 12 / 24,
  },
];
const IndiLoanPlForm: React.FC = () => {
  const { user } = useModel('@@initialState', (ret) => {
    return {
      user: ret.initialState?.user,
    };
  });
  return (
    <CommonPage
      daoName={daoName}
      columns={columns}
      controls={controls}
      title="对公贷款批量"
      importName={importName}
      importControls={controls}
      importMode="TruncteAfterInsert"
      importParamNames={['ISTZ']}
      importParamVals={{ DSEM: '' + user?.userID }}
      importTemplateName="个人贷款批量"
      initSorter={{ FieldName: 'KHMC', Direction: 'DESC' }}
    />
  );
};

export default IndiLoanPlForm;
